//
//  StatusRetweetView.swift
//  新浪微博
//
//  Created by seteny on 16/7/14.
//  Copyright © 2016年 seteny. All rights reserved.
//

import UIKit

class StatusRetweetView: UIView {

    // 持有的viewModel
    var statusViewModel: StatusViewModel? {
        didSet {
            //设置转发微博内容
            contentLabel.text = statusViewModel?.retweetContent
        }
    }
    
    // MARK:  -- 懒加载控件
    private lazy var contentLabel: UILabel = {
        let label = UILabel(textColor: UIColor.grayColor(), fontSize: 14)
       //多行显示
        label.numberOfLines = 0
        return label
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
    
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // 添加视图设置约束
    private func setupUI() {
        contentLabel.backgroundColor = UIColor(white: 0.95, alpha: 1)
        //添加控件
        addSubview(contentLabel)
        //设置约束
        contentLabel.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self).offset(HomeCellMargin)
            make.leading.equalTo(self).offset(HomeCellMargin)
            make.trailing.equalTo(self).offset(-HomeCellMargin)
        }
        
        
        //关键的约束
        // 转发微博视图的底部约束等于我们转发内容label的底部约束加上一个间距
        self.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(contentLabel).offset(HomeCellMargin)
        }
    }

}
